package com.taptech.doufu.bean;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.taptech.doufu.R;
import com.taptech.doufu.bean.personalcenter.MineGroupBean;
import com.taptech.doufu.services.personalcenter.AccountService;

public class MineContentBean extends BaseBean
{

    Context mContext;

    //此处必须按json返回的数组名命名
    private MineTopicBean[] topics;
    private MineNovelBean[] novels;
    private MineNovelReviewBean[] novel_reviews;
    // 群组信息
    private MineGroupBean[] groups;
    private PersonalNoteBean[] journals;
    private UserBean2 user;

    public MineGroupBean[] getGroups()
    {
        return groups;
    }

    public void setGroups(MineGroupBean[] groups)
    {
        this.groups = groups;
    }

    public UserBean2 getUser()
    {
        return user;
    }

    public void setUser(UserBean2 user)
    {
        this.user = user;
    }

    private String[] orders;

    private String nickname;

    public String getAd_text_vip() {
        return ad_text_vip;
    }

    public void setAd_text_vip(String ad_text_vip) {
        this.ad_text_vip = ad_text_vip;
    }

    private String ad_text_vip;

    private List<MineAbstractBean> mDisplayBeanList;

    public MineContentBean(Context context)
    {
        this.mContext = context;
    }

    public String getNickname()
    {
        return nickname;
    }

    public void setNickname(String nickname)
    {
        this.nickname = nickname;
    }

    public boolean hasContent(){
        if (topics == null && novels == null && novel_reviews == null && groups == null && journals == null ){
            return false;
        }else {
            return true;
        }
    }

    public List<MineAbstractBean> getDisplayBeanList()
    {
        if (orders != null)
        {
            mDisplayBeanList = new ArrayList<MineAbstractBean>();
            for (String temporder : orders)
            {
                if (temporder.equals("topics"))
                {
                    MineContentTitleBean typebean = new MineContentTitleBean();
                    typebean.setTypeString("话题");
                    typebean.setUserId(user.getUid());
                    typebean.setUserBean(user);
                    typebean.setTypeContentCount(user.getTopic_count());
                    mDisplayBeanList.add(typebean);
                    for (MineAbstractBean bean : topics)
                    {
                        mDisplayBeanList.add(bean);
                    }
                } else if (temporder.equals("novels"))
                {
                    MineContentTitleBean typebean = new MineContentTitleBean();
                    typebean.setTypeString("小说");
                    typebean.setUserId(user.getUid());
                    typebean.setUserBean(user);
                    typebean.setTypeContentCount(user.getNovel_count());
                    mDisplayBeanList.add(typebean);
                    for (MineAbstractBean bean : novels)
                    {
                        mDisplayBeanList.add(bean);
                    }
                } else if (temporder.equals("novel_reviews"))
                {
                    MineContentTitleBean typebean = new MineContentTitleBean();
                    typebean.setTypeString("文评");
                    typebean.setUserId(user.getUid());
                    typebean.setUserBean(user);
                    typebean.setTypeContentCount(user.getNovel_review_count());
                    mDisplayBeanList.add(typebean);
                    for (MineAbstractBean bean : novel_reviews)
                    {
                        mDisplayBeanList.add(bean);
                    }
                } else if (temporder.equals("journals"))
                {
                    MineContentTitleBean typebean = new MineContentTitleBean();
                    typebean.setTypeString(mContext.getResources().getString(R.string.personal_note_name));
                    typebean.setUserId(user.getUid());
                    typebean.setUserBean(user);
                    typebean.setTypeContentCount(user.getJournal_count());
                    mDisplayBeanList.add(typebean);
                    for (PersonalNoteBean bean : journals)
                    {
                        mDisplayBeanList.add(bean);
                    }
                } else if (temporder.equals("groups") && !AccountService.getInstance().isUserSelf(user.getUid()))
                {
                    // 加入组群
                    if (groups != null)
                    {
                        MineContentTitleBean typebean = new MineContentTitleBean();
                        typebean.setTypeString("群组");
                        typebean.setUserId(user.getUid());
                        typebean.setUserBean(user);
                        typebean.setTypeContentCount(user.getGroup_count());
                        mDisplayBeanList.add(typebean);
                        for (MineAbstractBean bean : groups)
                        {
                            MineGroupBean groupBean = (MineGroupBean) bean;
                            groupBean.setUserBean(user);
                            mDisplayBeanList.add(groupBean);
                        }
                    }
                }

            }

        }

        return mDisplayBeanList;
    }

    public MineTopicBean[] getTopics()
    {
        return topics;
    }

    public void setTopics(MineTopicBean[] topics)
    {
        this.topics = topics;
    }

    public MineNovelBean[] getNovels()
    {
        return novels;
    }

    public void setNovels(MineNovelBean[] novels)
    {
        this.novels = novels;
    }

    public MineNovelReviewBean[] getNovel_reviews()
    {
        return novel_reviews;
    }

    public void setNovel_reviews(MineNovelReviewBean[] novel_reviews)
    {
        this.novel_reviews = novel_reviews;
    }

    public String[] getOrder()
    {
        return orders;
    }

    public void setOrder(String[] orders)
    {
        this.orders = orders;
    }

    public void setPersonalNoteBeans(PersonalNoteBean[] personalNoteBeans)
    {
        this.journals = personalNoteBeans;
    }
}
